Flat memory model or linear memory model refers to a memory addressing paradigm in low-level software design such that the CPU can directly (and sequentially/linearly) address all of the available memory locations without having to resort to any sort of memory segmentation or paging schemes.
Memory management and logical-to-physical address translation can still be implemented on top of a flat memory model in order to facilitate the operating system's functionality, resource protection, multitasking or to increase the memory capacity beyond the limits imposed by the processor's physical address space, but the key feature of a flat memory model is that the entire memory space is linear, sequential and contiguous from address zero to MaxBytes-1.
Memory management is therefore optional; it is neither necessary, nor dictated by the CPU architecture:
The vast majority of processor architectures do implement a flat memory design, including all early 8-bit processors, the Motorola 68K series, etc. The original Intel 8086 was an exception to this rule which implemented a segmented memory model, because it provided an easy form of memory management with flexible page boundaries for early operating systems such as DOS and allowed access to an address space greater than what would otherwise be available with its 16-bit addressing.
Contents |
Most modern memory models fall into one of three categories:
Within the x86 architectures, when operating in the real (compatible) mode, physical address is computed as:
Address = 16*segment + offset
(e.g. The 16-bit segment register is shifted left by 4 bits and added to a 16-bit offset, resulting in a 20-bit address.)
Finally, there seems to be some confusion regarding the relationship between a flat memory model and Von Neumann vs Harvard architectures.
A Von Neumann architecture specifies that instructions and data are both stored within the same memory and transferred over the same bus. This type of architecture is the most space efficient, because any memory not used by the program is available for data and vice versa. It is most often used in general computing.
A Harvard architecture, on the other hand, separates instructions and data into two separate memories which are typically accessed over two separate buses. The benefit is an increase in system performance because data (for the present instruction) and code (for the future instruction) can be fetched at the same time. Also, in a Harvard architecture, the instruction and data buses can have different speeds and geometries. The drawback is that Harvard architectures force the designer to make assumptions about the ratio of instruction vs data memory, and this memory cannot be re-allocated at run time. The system is therefore unavoidably more wasteful. This type of architecture is most often used in digital signal processing (DSP), real-time control and ultra high-speed RISC applications, where performance is of utmost importance and everything else is secondary.
The point is that neither of the above architectures makes any claims whether the memory addressing model is flat, segmented, paged or otherwise.